import Vue from 'vue'
import VueRouter from 'vue-router'
import login from '../views/loginPage.vue'
import home from '../views/home/motherPage.vue'
import userlist from '../components/aside/user/userList.vue'
import peoplelist from '../components/aside/rights/peopleList.vue'
import rightlist from '../components/aside/rights/rightList.vue'
import goodslist from '../components/aside/goods/goodsList.vue'
import classpage from '../components/aside/goods/classPage.vue'
import goodsclass from '../components/aside/goods/goodsClass.vue'
import order from '../components/aside/order/orderList.vue'
import data from '../components/aside/datas/dataList.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: home,
    redirect: '/login',
    children: [
      {
        path: '/userlist',
        name: 'userlist',
        component: userlist,
        beforeEnter: (to, from, next) => {
          console.log('独享守卫')
          next()
        }
      },
      {
        path: '/peoplelist',
        name: 'peoplelist',
        component: peoplelist
      },
      {
        path: '/rightlist',
        name: 'rightlist',
        component: rightlist
      },
      {
        path: '/goodslist',
        name: 'goodslist',
        component: goodslist
      },
      {
        path: '/classpage',
        name: 'classpage',
        component: classpage
      },
      {
        path: '/goodsclass',
        name: 'goodsclass',
        component: goodsclass
      },
      {
        path: '/order',
        name: 'order',
        component: order
      },
      {
        path: '/data',
        name: 'data',
        component: data
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: login

  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
